import 'package:flutter/material.dart';
import 'package:ljy_flutter/change_notifier_proxy_privoder_ex/models/book_model.dart';
import 'package:ljy_flutter/change_notifier_proxy_privoder_ex/widgets/book_button.dart';
import 'package:provider/provider.dart';

class BookItem extends StatelessWidget {
  final int id;

  const BookItem({super.key, required this.id});

  @override
  Widget build(BuildContext context) {
    var bookModel = Provider.of<BookModel>(context);
    var book = bookModel.getById(id);

    return ListTile(
      leading: CircleAvatar(child: Text('${book.bookId}')),
      title: Text(book.bookName, style: TextStyle(color: Colors.black87)),
      trailing: BookButton(book: book),
    );
  }
}
